package com.example.demo.sql.condition;

import net.sf.jsqlparser.expression.*;
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;

public class Condition {
    private String columnName;
    private Object value;
    private Table table;

    public Condition(String columnName, Object value, Table table) {
        this.columnName = columnName;
        this.value = value;
        this.table = table;
    }

    public Expression toExpression() {
        Column column = new Column(table, columnName);
        if (value instanceof String) {
            return new EqualsTo(column, new StringValue((String) value));
        } else if (value instanceof Long) {
            return new EqualsTo(column, new LongValue((Long) value));
        }
        throw new IllegalArgumentException("Unsupported value type: " + value.getClass());
    }
}
